<template>
	<view class="content padding fafafa">
		<view class="ffffff border_2" v-if="invoiceInfo.invoice.invoice_image">
			<image :src="invoiceInfo.invoice.invoice_image" mode="" class="invoiceImage"></image>
		</view>
		<view class="saveInvoice margin_top" v-if="invoiceInfo.invoice.invoice_image" @click="downLoad">
			保存发票
		</view>
		<view class="padding ffffff margin_top border_2">
			<view class="text_x color_ling">
				订单编号：{{invoiceInfo.order_no}}
			</view>
			<view class="margin_top flexleft" v-for="item in invoiceInfo.ordergoods" :key="item.id">
				<view class="imgBox margin_right3">
					<image :src="item.goods_image_text" mode="widthFix"></image>
				</view>
				<view class="flex1 width0">
					<view class="yihang text_a color_san">
						{{item.goods_name}}
					</view>
					<view class="text_b color_jiu margin_top1">
						{{item.sku}}
					</view>
					<view class="flexbetween margin_top1">
						<view class="price">
							￥{{item.total_price}}
						</view>
						<view class="color_jiu text_six">
							x{{item.goods_num}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="padding ffffff margin_top border_2">
			<view class="text_x color_ling">
				发票类型
			</view>
			<view class="margin_top4">
				<view class="text_a color_six">
					发票类型：{{invoiceInfo.invoice.invoice_type==1?"电子发票":"增值税专用发票"}}
				</view>
				<view class="text_a color_six margin_top">
					抬头类型：{{invoiceInfo.invoice.invoice_detail.invoice_title_type==1?"个人":"单位"}}
				</view>
				<view class="text_a color_six margin_top">
					抬头名称：{{invoiceInfo.invoice.invoice_detail.invoice_title}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.invoice_detail.tel">
					单位电话：{{invoiceInfo.invoice.invoice_detail.tel}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.invoice_detail.duty_paragraph">
					单位税号：{{invoiceInfo.invoice.invoice_detail.duty_paragraph}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.invoice_detail.bank_name">
					开户银行：{{invoiceInfo.invoice.invoice_detail.bank_name}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.invoice_detail.bank_code">
					银行账号：{{invoiceInfo.invoice.invoice_detail.bank_code}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.invoice_detail.address">
					单位地址：{{invoiceInfo.invoice.invoice_detail.address}}
				</view>
				<view class="text_a color_six margin_top">
					申请时间：{{invoiceInfo.invoice.createtime_text}}
				</view>
				<view class="text_a color_six margin_top" v-if="invoiceInfo.invoice.state==2">
					开票时间：{{invoiceInfo.invoice.updatetime_text}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				order_id: "", //发票id
				invoiceInfo:{
					invoice:{
						invoice_detail:{}
					}
				},//发票详情
			}
		},
		onLoad(options) {
			this.order_id = options.id
			this.getInvoiceInfo()
		},
		methods: {
			getInvoiceInfo() {
				let _this = this;
				httpRequest.request('/api/goods_order/invoice_detail', 'GET', {
					order_id: _this.order_id
				}, false, false, true).then(res => {
					if (res.code == 1) {
						if(res.data.invoice.invoice_image){
							res.data.invoice.invoice_image = _this.imgUrl + res.data.invoice.invoice_image
						}
						_this.invoiceInfo=res.data
					}else{
						httpRequest.toast(res.msg);
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			downLoad(){ //保存发票
				httpRequest.saveHttpImg(this.invoiceInfo.invoice.invoice_image)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.invoiceImage {
		width: 100%;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		// height: 100%;
	}

	.saveInvoice {
		padding: 20rpx;
		text-align: center;
		border-radius: 12rpx;
		background-color: rgba(243, 39, 28, 1);
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.imgBox {
		width: 124rpx;
		height: 124rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		overflow: hidden;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.price {
		font-size: 30rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: #F3271C;
	}
</style>